﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[System.Obsolete("使用BossPowerPoint")]
public class BossPPT : MonoBehaviour
{
    List<BossPage> pages = new List<BossPage>();
    int current = 0;

    private void Awake()
    {
        int i = 0;
        foreach (var item in transform.GetComponentsInChildren<BossPage>())
        {
            pages.Add(item);
            item.Index = i++;
            item.gameObject.SetActive(false);
        }
        pages[current].gameObject.SetActive(true);
    }

    // Update is called once per frame
    void Update()
    {
        if (pages[current].ToJumpSelf)
        {
            pages[current].gameObject.SetActive(false);
            pages[current].gameObject.SetActive(true);
        }
        else if (pages[current].ToJump)
        {
            Jump(current + 1);
        }
        pages[current].ToJump = false;
        pages[current].ToJumpSelf = false;

    }

    private void Jump(int index)
    {
        pages[current].ToJump = false;
        pages[current].gameObject.SetActive(false);
        current = index;
        current %= pages.Count;
        pages[current].gameObject.SetActive(true);
        Debug.Log($"BossPPT: 跳转到页{current}");
    }

    public void Jump(BossPage bossPage)
    {
        Jump(bossPage.Index);
    }

    public void JumpToEnd()
    {
        Jump(pages.Count - 1);
    }
}
